package com.itheima.dao.impl;

import com.itheima.dao.BookDao;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

//1.声明被扫描@Repository(持久层) = @Component(其他)
//@Repository
//使用@Scope定义bean作用范围
//@Scope("singleton")
@Repository("bookDao")
public class BookDaoImpl implements BookDao {
    //@Value：注入简单类型（无需提供set方法）
    @Value("${name}")
    private String name;
//    @Value("${age}")
//    private int age;
    @Override
    public void save() {
        System.out.println("BookDaoImpl save... name:" +name);
//        System.out.println("BookDaoImpl save... age:" +age);
    }
//    public BookDaoImpl(){
//        System.out.println("BookDaoImpl...");
//    }
//    @PostConstruct
//    public void init() {
//        System.out.println("PostConstruct init...");
//    }
//    @PreDestroy
//    public void destroy() {
//        System.out.println("PreDestroy destroy...");
//    }
}

